package springinpractice.ch2.service;

import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import springinpractice.ch2.dao.EmployeeDao;
import springinpractice.ch2.model.Employee;

/*
 * @author	Willie Wheeler John Wheeler and Zeeshan Maqbool
 * Book		'Spring In Practice' [Book written by Willie Wheeler and John Wheeler]
 * 
 */

@Service
@Transactional(readOnly = true)
public class HumanResourcesService
{

	private static final Log logger = LogFactory.getLog(HumanResourcesService.class);
	
	@Autowired
	private EmployeeDao employeeDao;

	public Employee findEmployeeById(long id)
	{
		logger.debug("finding employee with id " + id);
		return employeeDao.findById(id);
	}
	
	@Transactional(readOnly = false)
	public void saveEmployee(Employee employee)
	{
		logger.debug("saving new employee");
		employeeDao.save(employee);
	}

}